package controller

import (
	"github.com/gin-gonic/gin"
	"strconv"
)

func IntPostForm(ctx *gin.Context, key string) int {
	data := ctx.PostForm(key)
	intValue, err := strconv.Atoi(data)
	if err != nil {
		panic(err.Error())
	}

	return intValue
}

func IntDefaultPostForm(ctx *gin.Context, key string, defaultValue string) int  {
	data := ctx.DefaultPostForm(key, defaultValue)
	intValue, err := strconv.Atoi(data)
	if err != nil {
		panic(err.Error())
	}

	return intValue
}
